Skip to main content

messageAuthenticationCode

Type

function

Summary

Compute a message authentication code.

Syntax

messageAuthenticationCode(<message>, <key>, <codeType>)

Description

messageAuthenticationCode provides a way to check the integrity of information transmitted over or stored in an unreliable medium is a prime necessity in the world of open computing and communications. Mechanisms that provide such integrity check based on a secret key are usually called "message authentication codes" (MAC). Typically, message authentication codes are used between two parties that share a secret key in order to validate information transmitted between these parties. messageAuthenticationCode also uses a secret key for calculation of the message authentication values.

Parameters

NameTypeDescription

message

A binary data string.

key

A binary data string.

codeType

The cryptographic hash function to use

  • "HMAC-SHA3-224":
  • "HMAC-SHA3-256":
  • "HMAC-SHA3-384":
  • "HMAC-SHA3-512":
  • "HMAC-SHA-224":
  • "HMAC-SHA-256":
  • "HMAC-SHA-384":
  • "HMAC-SHA-512":
  • "HMAC-SHA-1": Use only for backwards compatibility
  • "HMAC-MD5": Use only for backwards compatibility

Examples

local tHMAC
put messageAuthenticationCode("My Data", "My Secret", "HMAC-SHA-256") into tHMAC

function: messageDigest

glossary: binary data